package driver;

import model.searchers.ISearcher;
import model.searchers.SearcherFactory;
import view.*;
import controller.*;

public class Driver {

	/**
	 * main method of search engine project. Creates the model, view and controller objects. 
	 * @param args Usage: java Driver <datafile> <searchertype> <viewtype> <mode>
	 */
	public static void main(String[] args)  {
		
		// Check that exactly 5 arguments have been given
		if (args.length != 5) {
			System.out.println("Usage: java Driver <datafile> <searchertype> <viewtype> <mode> <pagerank>");
			System.exit(1);
		}
		
		//Retrieve data from command line arguments
		String dataFile = args[0];
		String searcherType = args[1];
		String viewType = args[2];
		boolean mode = (args[3].equals("1"));
		boolean ranking = (args[4].equals("1"));
		
		/* Create Model - View - Controller objects
		   SearcherFactory and ViewFactory the factory pattern to create 
		   objects depending on the input from the command line.
		*/
		ISearcher model = SearcherFactory.createSearcher(dataFile,searcherType, mode, ranking);
		Controller ctrl = new Controller(model);
		@SuppressWarnings("unused")
		IView view = ViewFactory.createView(viewType, mode, ctrl);
	}
}
